package com.devicemantra.coordinate.interfaces.email;

import java.io.IOException;
import java.util.Date;

import javax.servlet.http.*;



import com.devicemantra.coordinate.util.CLogger;
import com.google.appengine.api.labs.taskqueue.Queue;
import com.google.appengine.api.labs.taskqueue.QueueFactory;
import com.google.appengine.api.labs.taskqueue.TaskHandle;
import com.google.appengine.api.labs.taskqueue.TaskOptions.Method;

import static com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.*;


@SuppressWarnings("serial")
public class EmailTask extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		
		CLogger.log("Email task started");
		String lEmailAddress = req.getParameter("email_address");
		String lSubject = req.getParameter("subject");
		String lBody = req.getParameter("body");
		CSendEmail.sendMail(lEmailAddress, lSubject, lBody);
		CLogger.log("Sent email to " + lEmailAddress);
		System.out.println("Sent email to " + lEmailAddress);
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
	throws IOException 
	{
		doGet(req,resp);
	}
}
